<%@ page contentType="text/html; charset=utf-8" %>
<%@ include file="/WEB-INF/jsp/includeTaglib.jsp" %>


	<form id="salesPromoterListForm">
		<div class="globalText" style="padding: 15px;border: solid 1px #999999;margin: 15px;" >
			<table class="globalText dbborder" width="100%" border="0" cellpadding="5" cellspacing="5" style="margin: 5px;">
				<tr>
					<td>促销员姓名</td>
					<td>
						<input  name="salesPromoterName"  type="text" class="txtbox " size="20" />
					</td>
					<td>系统类型</td>
					<td>
						<select name="sysCategory" >
							<option></option>
							<c:forEach var="pos" items="${sysPosKindList}" >
								<option value="${pos.code}">${pos.name}</option>
							</c:forEach>
						</select>
					</td>
					<td>通路类别</td>
					<td>
						<select name="category" >
							<option></option>
							<c:forEach var="pos" items="${posKindList}" >
								<option value="${pos.id}">${pos.name}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				
				<tr>
					<td>门店编号</td>
					<td>
						<input  name="storeCode"  type="text" class="txtbox " size="20" />
					</td>
					<td>门店</td>
					<td>
						<select id="storeSelectList" name="storeName">
							<option></option>
							<c:forEach var="store" items="${allStores}" >
								<option value="${store.channel.channel.name}">${store.channel.channel.name}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				
				
				<tr>
					<td>地区</td>
					<td colspan="2">
					
						<select name="provinceName" id="provinceSelList" onchange="findDivision('1',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text)" >
							<option value="">--</option>
							<c:forEach var="ad" items="${provinceList}" >
								<option value="${ad.code}">${ad.name}</option>
							</c:forEach>
						</select>
						<select name="cityName" id="citySelList" onchange="findDivision('2',this.options[this.selectedIndex].value,this.options[this.selectedIndex].text)">
							<option value="">--</option>
						</select>
						<select name="disName" id="disSelList">
							<option value="">--</option>
						</select>
						
						
						<input type="hidden" name="adId" id="adId" value="" />
					<td>
					</td>
				</tr>
				
				
				<tr>
					<td align="center" colspan="4">
						<input style="margin-left: 0px;" onclick="javascript:
						if($('#disSelList').val()!=''){
							$('#adId').val($('#disSelList').val());
						}else if($('#citySelList').val()!=''){
							$('#adId').val($('#citySelList').val());
						}else if($('#provinceSelList').val()!=''){
							$('#adId').val($('#provinceSelList').val());
						}else{
							$('#adId').val('');
						}
						listDefaultPageAjax('salesPromoterAssignListData','salesPromoterListForm','<c:url value='/project/projectSalesPromoterAssignListData.html' />');" type="button" class=" btnStyle" value="提交" />
					</td>
				</tr>
			</table>
		</div>
		<input type="hidden" name="projectId" value="${projectId}" />
	</form>
	
	
<div class="pageDiv" id="salesPromoterAssignListData" >
		
</div>


<script>
	listDefaultPageAjax('salesPromoterAssignListData','salesPromoterListForm','<c:url value='/project/projectSalesPromoterAssignListData.html' />');
	
    $(document).ready(function() { $("#storeSelectList").select2(); });
    
    function findDivision(depth,code,adname){
    	
		$.ajax({
			   type: "POST",
			   url: "<c:url value='/json/findAdminDivisions.html' />",
			   data: "adname="+encodeURIComponent(adname)+"&depth="+depth+"&code="+code,
			   dataType: "json",
			   success: function(msg){
				    var sel;
			    	if(depth==1){
			    		sel=$("#citySelList")
			    		$("#citySelList").empty();
			    		$("#disSelList").empty();
			    		
			    		$("#citySelList").append("<option value='''>--</option>");
			    		$("#disSelList").append("<option value='''>--</option>");
			    	}else if(depth==2){
			    		sel=$("#disSelList");
			    		$("#disSelList").empty();
			    		$("#disSelList").append("<option value='''>--</option>");
			    	}
			    	
			    	sel.empty();
			    	sel.append("<option value='''>--</option>");
		    		for(var i=0;i<msg.length;i++){
		    			sel.append("<option value="+msg[i].id+">"+msg[i].name+"</option>");
		    		}
			   }
			});
	}
</script>

